<template>
    <div class="photoInfo_container">
        <h3>{{photoContent.title}}</h3>
        <div class="header_div">
            <div class="header_time">发表时间:{{photoContent.add_time | dataFormat}}</div>
            <div class="header_click">点击:{{photoContent.click}}次</div>
        </div>
        <hr>

        <!-- 缩略图区域 -->
        <div class="thumbs">
            <!-- <img class="preview-img" v-for="(item,index) in list" :src="item.src" height="100" @click="$preview.open(index,list)" :key="item.src"> -->
            <vue-preview :slides="list" @close="handleClose"></vue-preview>
        </div>

        <!-- 图片内容区域 -->
        <div class="content">{{photoContent.content}}</div>

        <!-- 发表评论子组件 -->
        <cmt-box></cmt-box>
    </div>
</template>
<script>
import comments from '../../subcomponents/comment.vue';
export default {
    data(){
        return {
            id:this.$route.params.id,
            photoContent:[],
            list:[]
        }
    },
    created(){
        this.getPhotoContent();
        this.getThumbs();
    },
    methods:{
        getPhotoContent(){
            this.$http.get("photo/photoInfo/"+this.id+".json").then(result=>{
                if(result.body.status===0){
                    this.photoContent = result.body.message[0];
                }
            })
        },
        getThumbs(){
            this.$http.get("photo/photoInfo/thumbs/"+this.id+".json").then(result=>{
                if(result.body.status===0){
                    result.body.message.forEach(item => {
                        item.w=600;
                        item.h=400;
                    });
                };
                this.list = result.body.message;
            })
        },
        handleClose(){
            console.log('close event')
        }
    },
    components:{
        "cmt-box":comments
    }
}
</script>
<style scoped>
    .photoInfo_container{
        padding: 3px;
    }
    .photoInfo_container>h3{
        color: #26A2FF;
        font-size: 15px;
        text-align: center;
        margin: 15px 0;
    }
    .photoInfo_container .header_div{
        display: flex;
        justify-content: space-between;
        font-size: 13px;
        color: #ccc;
    } 
    .photoInfo_container .content{
        font-size: 13px;
        line-height: 30px; 
    }
    .photoInfo_container .thumbs>img{
        margin: 10px;
        box-shadow: 0 0 9px #999;
    }
</style>
